# Maintainer: Alexey Pavlov <alexpux@gmail.com>

_realname=udsoncan
pkgbase=mingw-w64-python-${_realname}
pkgname=("${MINGW_PACKAGE_PREFIX}-python-${_realname}")
provides=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
conflicts=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
replaces=("${MINGW_PACKAGE_PREFIX}-python3-${_realname}")
pkgver=1.13.1
pkgrel=1
pkgdesc="Implementation of the Unified Diagnostic Services (UDS) protocol defined by ISO-14229 written in Python 3 (mingw-w64)"
arch=('any')
url='https://github.com/pylessard/python-udsoncan'
license=('MIT')
depends=("${MINGW_PACKAGE_PREFIX}-python")
makedepends=("${MINGW_PACKAGE_PREFIX}-python"
             "${MINGW_PACKAGE_PREFIX}-python-setuptools")
options=('staticlibs' 'strip' '!debug')
source=("${_realname}-${pkgver}.tar.gz"::"https://github.com/pylessard/python-udsoncan/archive/v${pkgver}.tar.gz")
sha512sums=('8dd1a8ad712bbae45b977c6a258874cc267911005c5caf523b72bd4e6a6f2700a8f64eb022b1a1b10ed56e91bc3cafad4437715d5ce6c439457783a66ecd2526')

prepare() {
  cp -rf python-${_realname}-${pkgver} python-build-${CARCH}
}

build() {
  msg "Python build for ${CARCH}"  
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py build
}

package() {
  cd "${srcdir}/python-build-${CARCH}"
  MSYS2_ARG_CONV_EXCL="--prefix=;--install-scripts=;--install-platlib=" \
    ${MINGW_PREFIX}/bin/python setup.py install --prefix=${MINGW_PREFIX} \
    --root="${pkgdir}" --optimize=1 --skip-build

  install -Dm644 LICENSE.txt "${pkgdir}${MINGW_PREFIX}/share/licenses/python-${_realname}/LICENSE.txt"
}
